package com.apes.fn.server.productReturn;

import com.apes.framework.jpa.repository.CustomRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Date;
import java.util.Map;

public interface ProductReturnRepository extends CustomRepository<ProductReturn, String> {

    @Query("select sum(p.qtyReturn) as qtyReturn from ProductReturnItem p where p.productReturn.location.depot.dept.id = :deptId " +
            "and p.productReturn.state = 'approve' and p.productReturn.approveDate > :startDate and p.productReturn.approveDate < :endDate ")
    Map<String, Object> findProductReturnQty(@Param("deptId") String deptId, Date startDate, Date endDate);
}
